home *** CD-ROM | disk | FTP | other *** search
/ APC & TCP 5 / APC & TCP 5.iso / tools / preview / other / wildfire / --please-test-it! / yp_beta2 / yp_to24.s < prev    next >
Text File  |  1997-08-28  |  7KB  |  342 lines

  1.  
  2.  
  3.  
  4. ;these routines are used to convert the YAFA frames to 24Bit RGB
  5. ;which is then used as input for WritePixelArray()
  6.  
  7.  
  8.  
  9. ;-------------------------------------------------------------------------
  10. ; 15bit-Truecolor to 24bit-Truecolor  by Smack/Infect! 23-Aug-97
  11. ;
  12. ;  input   0rrrrrgg gggbbbbb
  13. ;  output  rrrrrrrr gggggggg bbbbbbbb
  14. ;
  15. ; parameters on stack:
  16. ;  00  APTR    source
  17. ;  04  APTR    dest
  18. ;  08  ULONG   number_of_pixels
  19. ;
  20. _color15to24
  21.     movem.l    d0-a6,-(a7)    ;15*4+4=64
  22.     move.l    (64+00,a7),a5    ;source
  23.     move.l    (64+04,a7),a6    ;dest
  24.     move.l    (64+08,a7),d7    ;pixels
  25.     lsr.l    #2,d7
  26.     moveq    #19,d6
  27.     moveq    #10,d5
  28.     moveq    #18,d4
  29.     moveq    #11,d3
  30. .loop    move.l    (a5)+,d0    ;two pixels
  31.     move.l    d0,d1
  32.     lsr.l    d5,d0        ;#10
  33.     lsl.b    #3,d0
  34.     move.b    d0,d2
  35.     lsr    #3,d0
  36.     lsr.b    #3,d0
  37.     lsl.l    d3,d0        ;#11
  38.     move.b    d2,d0        ;RGBr
  39.     move.l    d0,(a6)+
  40.     lsl    #3,d1
  41.     move.l    (a5)+,d0    ;two pixels
  42.     lsr.b    #3,d1
  43.     move.l    d0,d2
  44.     lsl.l    d6,d1        ;#19  gb__
  45.     lsr.l    d4,d0        ;#18
  46.     lsr.b    #3,d0
  47.     lsl    #3,d0
  48.     move    d0,d1        ;gbRG
  49.     move.l    d1,(a6)+
  50.     move.l    d2,d0
  51.     lsr    #2,d2
  52.     lsl.b    #3,d0
  53.     lsr.b    #3,d2
  54.     lsl.l    d3,d2        ;#11
  55.     move.b    d0,d2        ;Brgb
  56.     move.l    d2,(a6)+
  57.     subq.l    #1,d7
  58.     bgt.b    .loop
  59.     movem.l    (a7)+,d0-a6
  60.     rts
  61. ;-------------------------------------------------------------------------
  62. LUT        ds.l    256
  63. ;-------------------------------------------------------------------------
  64. ; 8bit-ChunkyPixels to 24bit-Truecolor  by Smack/Infect! 08-Aug-97
  65. ;
  66. ;  input   all 8 bits are used here,
  67. ;          this requires unused bits (if depth<8) to be cleared (ZER0)!
  68. ;  output  rrrrrrrr gggggggg bbbbbbbb
  69. ;
  70. ; parameters on stack:
  71. ;  00  APTR            source
  72. ;  04  APTR            dest
  73. ;  08  ULONG           number_of_pixels
  74. ;  12  struct loadrgb* palette 
  75. ;
  76. _chunkyto24
  77.     movem.l    d0-a6,-(a7)    ;15*4+4=64
  78.  
  79.     move.l    (64+12,a7),a0
  80.     move    (a0),d7
  81.     subq    #1,d7        ;count
  82.     addq.l    #4,a0
  83.     lea    (LUT,pc),a4
  84.     move.l    a4,a1
  85. .makLUT    move.l    (a0)+,d1
  86.     move.l    (a0)+,d2
  87.     move.l    (a0)+,d3
  88.     moveq    #0,d0
  89.     rol.l    #8,d1
  90.     rol.l    #8,d2
  91.     rol.l    #8,d3
  92.     move.b    d1,d0    ;R
  93.     lsl.l    #8,d0
  94.     move.b    d2,d0    ;G
  95.     lsl.l    #8,d0
  96.     move.b    d3,d0    ;B
  97.     move.l    d0,(a1)+
  98.     dbf    d7,.makLUT
  99.  
  100.     move.l    (64+00,a7),a5    ;source
  101.     move.l    (64+04,a7),a6    ;dest
  102.     move.l    (64+08,a7),d7    ;pixels
  103.     lsr.l    #2,d7
  104.     moveq    #24,d6
  105.     moveq    #0,d0
  106.     moveq    #0,d1
  107. .loop    move.b    (a5)+,d0
  108.     move.b    (a5)+,d1
  109.     move.l    (a4,d0.l*4),d2
  110.     move.l    (a4,d1.l*4),d3
  111.     lsl.l    #8,d2        ;RGB_
  112.     swap    d3        ;gb_r
  113.     move.b    d3,d2        ;RGBr
  114.     move.l    d2,(a6)+
  115.     move.b    (a5)+,d0
  116.     move.b    (a5)+,d1
  117.     move.l    (a4,d0.l*4),d4
  118.     move.l    d4,d2
  119.     lsr.l    #8,d4
  120.     lsl.l    d6,d2        ;B___
  121.     move    d4,d3        ;gbRG
  122.     move.l    d3,(a6)+
  123.     or.l    (a4,d1.l*4),d2    ;Brgb
  124.     move.l    d2,(a6)+
  125.     subq.l    #1,d7
  126.     bgt.b    .loop
  127.  
  128.     movem.l    (a7)+,d0-a6
  129.     rts
  130. ;-------------------------------------------------------------------------
  131. ; 8bit-ChunkyPixels HAM8 to 24bit-Truecolor  by Smack/Infect! 08-Aug-97
  132. ;
  133. ;  input   76543210 (bits 6 and 7 are the HAM8 control codes)
  134. ;  output  rrrrrrrr gggggggg bbbbbbbb
  135. ;
  136. ; parameters on stack:
  137. ;  00  APTR            source
  138. ;  04  APTR            dest
  139. ;  08  ULONG           number_of_pixels
  140. ;  12  struct loadrgb* palette 
  141. ;
  142. _ham8to24
  143.     movem.l    d0-a6,-(a7)    ;15*4+4=64
  144.  
  145.     move.l    (64+12,a7),a0
  146.     move    (a0),d7
  147.     subq    #1,d7        ;count
  148.     addq.l    #4,a0
  149.     lea    (LUT,pc),a4
  150.     move.l    a4,a1
  151. .makLUT    move.l    (a0)+,d1
  152.     move.l    (a0)+,d2
  153.     move.l    (a0)+,d3
  154.     moveq    #0,d0
  155.     rol.l    #8,d1
  156.     rol.l    #8,d2
  157.     rol.l    #8,d3
  158.     move.b    d1,d0    ;R
  159.     lsl.l    #8,d0
  160.     move.b    d2,d0    ;G
  161.     lsl.l    #8,d0
  162.     move.b    d3,d0    ;B
  163.     move.l    d0,(a1)+
  164.     dbf    d7,.makLUT
  165.  
  166.     move.l    (64+00,a7),a5    ;source
  167.     move.l    (64+04,a7),a6    ;dest
  168.     move.l    (64+08,a7),d7    ;pixels
  169.     move.b    #%00000011,d6
  170.     moveq    #0,d0
  171.     moveq    #0,d2
  172.     moveq    #0,d3
  173.     moveq    #0,d4
  174. .loop    move.b    (a5)+,d0
  175.     move.b    d0,d1
  176.     lsr.b    #6,d1        ;control code
  177.     bne.b    .ham
  178.     ;-------select new base register
  179.     move.l    (a4,d0.l*4),d2
  180.     move.b    d2,d4        ;Blue
  181.     lsr.l    #8,d2
  182.     move.b    d2,d3        ;Green
  183.     lsr.l    #8,d2        ;Red
  184.     move.b    d2,(a6)+
  185.     move.b    d3,(a6)+
  186.     move.b    d4,(a6)+
  187.     subq.l    #1,d7
  188.     bgt.b    .loop
  189.     bra.b    .end
  190. .ham    ;-------hold and modify
  191.     lsl.b    #2,d0
  192.     subq.b    #1,d1
  193.     bne.b    .not_b
  194.     ;-------modify Blue
  195.     and.b    d6,d4
  196.     or.b    d0,d4        ;keep old 2 LSB
  197.     move.b    d2,(a6)+
  198.     move.b    d3,(a6)+
  199.     move.b    d4,(a6)+
  200.     subq.l    #1,d7
  201.     bgt.b    .loop
  202.     bra.b    .end
  203. .not_b    subq.b    #1,d1
  204.     bne.b    .not_r
  205.     ;-------modify Red
  206.     and.b    d6,d2
  207.     or.b    d0,d2        ;keep old 2 LSB
  208.     move.b    d2,(a6)+
  209.     move.b    d3,(a6)+
  210.     move.b    d4,(a6)+
  211.     subq.l    #1,d7
  212.     bgt.b    .loop
  213.     bra.b    .end
  214. .not_r    ;-------modify Green
  215.     and.b    d6,d3
  216.     or.b    d0,d3        ;keep old 2 LSB
  217.     move.b    d2,(a6)+
  218.     move.b    d3,(a6)+
  219.     move.b    d4,(a6)+
  220.     subq.l    #1,d7
  221.     bgt.b    .loop
  222. .end    movem.l    (a7)+,d0-a6
  223.     rts
  224. ;-------------------------------------------------------------------------
  225. ; 8bit-ChunkyPixels HAM6 to 24bit-Truecolor  by Smack/Infect! 08-Aug-97
  226. ;
  227. ;  input   __543210 (bits 4 and 5 are the HAM6 control codes,
  228. ;                    the unused bits 6 and 7 _MUST_ be cleared!)
  229. ;  output  rrrrrrrr gggggggg bbbbbbbb
  230. ;
  231. ; parameters on stack:
  232. ;  00  APTR            source
  233. ;  04  APTR            dest
  234. ;  08  ULONG           number_of_pixels
  235. ;  12  struct loadrgb* palette 
  236. ;
  237. _ham6to24
  238.     movem.l    d0-a6,-(a7)    ;15*4+4=64
  239.  
  240.     move.l    (64+12,a7),a0
  241.     move    (a0),d7
  242.     subq    #1,d7        ;count
  243.     addq.l    #4,a0
  244.     lea    (LUT,pc),a4
  245.     move.l    a4,a1
  246. .makLUT    move.l    (a0)+,d1
  247.     move.l    (a0)+,d2
  248.     move.l    (a0)+,d3
  249.     moveq    #0,d0
  250.     rol.l    #8,d1
  251.     rol.l    #8,d2
  252.     rol.l    #8,d3
  253.     move.b    d1,d0    ;R
  254.     lsl.l    #8,d0
  255.     move.b    d2,d0    ;G
  256.     lsl.l    #8,d0
  257.     move.b    d3,d0    ;B
  258.     move.l    d0,(a1)+
  259.     dbf    d7,.makLUT
  260.  
  261.     move.l    (64+00,a7),a5    ;source
  262.     move.l    (64+04,a7),a6    ;dest
  263.     move.l    (64+08,a7),d7    ;pixels
  264.     moveq    #%00001111,d5
  265.     moveq    #0,d0
  266.     moveq    #0,d2
  267.     moveq    #0,d3
  268.     moveq    #0,d4
  269. .loop    move.b    (a5)+,d0
  270.     move.b    d0,d1
  271.     lsr.b    #4,d1        ;control code
  272.     bne.b    .ham
  273.     ;-------select new base register
  274.     move.l    (a4,d0.l*4),d2
  275.     move.b    d2,d4        ;Blue
  276.     lsr.l    #8,d2
  277.     move.b    d2,d3        ;Green
  278.     lsr.l    #8,d2        ;Red
  279.     move.b    d2,(a6)+
  280.     move.b    d3,(a6)+
  281.     move.b    d4,(a6)+
  282.     subq.l    #1,d7
  283.     bgt.b    .loop
  284.     bra.b    .end
  285. .ham    ;-------hold and modify
  286.     lsl.b    #4,d0        ;modify the 4 MSB
  287.     subq.b    #1,d1
  288.     bne.b    .not_b
  289.     ;-------modify Blue
  290.     and.b    d5,d4
  291.     or.b    d0,d4        ;keep old 4 LSB
  292.     move.b    d2,(a6)+
  293.     move.b    d3,(a6)+
  294.     move.b    d4,(a6)+
  295.     subq.l    #1,d7
  296.     bgt.b    .loop
  297.     bra.b    .end
  298. .not_b    subq.b    #1,d1
  299.     bne.b    .not_r
  300.     ;-------modify Red
  301.     and.b    d5,d2
  302.     or.b    d0,d2        ;keep old 4 LSB
  303.     move.b    d2,(a6)+
  304.     move.b    d3,(a6)+
  305.     move.b    d4,(a6)+
  306.     subq.l    #1,d7
  307.     bgt.b    .loop
  308.     bra.b    .end
  309. .not_r    ;-------modify Green
  310.     and.b    d5,d3
  311.     or.b    d0,d3        ;keep old 4 LSB
  312.     move.b    d2,(a6)+
  313.     move.b    d3,(a6)+
  314.     move.b    d4,(a6)+
  315.     subq.l    #1,d7
  316.     bgt.b    .loop
  317. .end    movem.l    (a7)+,d0-a6
  318.     rts
  319.  
  320.  
  321.  
  322. _WPA_STUB
  323.     movem.l    d1-a6,-(a7)    ;14*4+4=60
  324.  
  325.     lea    (60,a7),a2
  326.  
  327.     move.l    (a2)+,a0    ;srcrect
  328.     move.l    (a2)+,d0    ;srcx
  329.     move.l    (a2)+,d1    ;srcy
  330.     move.l    (a2)+,d2    ;srcmod
  331.     move.l    (a2)+,a1    ;rastport
  332.     move.l    (a2)+,d3    ;destx
  333.     move.l    (a2)+,d4    ;desty
  334.     move.l    (a2)+,d5    ;sizex
  335.     move.l    (a2)+,d6    ;sizey
  336.     move.l    (a2)+,d7    ;srcformat
  337.     move.l    (a2),a6        ;cybergfxbase
  338.     jsr    (-$7e,a6)    ;WritePixelArray
  339.  
  340.     movem.l    (a7)+,d1-a6
  341.     rts
  342.